package fr.esipe.eioc3.timetableontime_v2;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.SyncStateContract.Columns;
import android.util.Log;

public class EventOpenHelper extends SQLiteOpenHelper {

    private static final String DATABASE_NAME = "event.db";
    private static final int DATABASE_VERSION = 2;

    public static final String EVENT_TABLE_NAME = "eventList";
    
    public static final String EVENT_COLUMN_FORMID 		= "formationId";
    public static final String EVENT_COLUMN_WEEKNUMBER 	= "weekNumber";
    public static final String EVENT_COLUMN_DAYOFMONTH 	= "dayOfMonth";
    public static final String EVENT_COLUMN_DAYOFWEEK 	= "dayOfWeek";
    public static final String EVENT_COLUMN_MONTH 		= "month";
    public static final String EVENT_COLUMN_YEAR 		= "year";
    public static final String EVENT_COLUMN_STARTHOUR 	= "startHour";
    public static final String EVENT_COLUMN_STARTMINUTE = "startMinute";
    public static final String EVENT_COLUMN_ENDHOUR 	= "endHour";
    public static final String EVENT_COLUMN_ENDMINUTE 	= "endMinute";
    public static final String EVENT_COLUMN_LABEL0 		= "label_0";
    public static final String EVENT_COLUMN_LABEL1 		= "label_1";
    public static final String EVENT_COLUMN_LABEL2 		= "label_2";
    public static final String EVENT_COLUMN_LABEL3 		= "label_3";
    public static final String EVENT_COLUMN_LABEL4 		= "label_4";
    


    private static final String EVENT_TABLE_CREATE = 
    		"CREATE TABLE " + EVENT_TABLE_NAME + " (" +	Columns._ID 		+ " INTEGER PRIMARY KEY, " +
    													EVENT_COLUMN_FORMID 	+ " TEXT," +
    													EVENT_COLUMN_WEEKNUMBER + " INTEGER," +
    													EVENT_COLUMN_DAYOFMONTH + " INTEGER," +
    													EVENT_COLUMN_DAYOFWEEK 	+ " INTEGER,"	+
    													EVENT_COLUMN_MONTH 		+ " INTEGER," +
    													EVENT_COLUMN_YEAR 		+ " INTEGER," +
    													EVENT_COLUMN_STARTHOUR 	+ " INTEGER," +
    													EVENT_COLUMN_STARTMINUTE + " INTEGER," +
														EVENT_COLUMN_ENDHOUR 	+ " INTEGER," +
														EVENT_COLUMN_ENDMINUTE 	+ " INTEGER," +
														EVENT_COLUMN_LABEL0 	+ " TEXT," +
														EVENT_COLUMN_LABEL1 	+ " TEXT," +
														EVENT_COLUMN_LABEL2 	+ " TEXT," +
														EVENT_COLUMN_LABEL3 	+ " TEXT," +
														EVENT_COLUMN_LABEL4 	+ " TEXT " + ");";
    
    public EventOpenHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(EVENT_TABLE_CREATE);
		Log.d("d 3","EVENT_TABLE_CREATE OK");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + EVENT_TABLE_NAME);
        onCreate(db);
    }

}
